import { ref, nextTick, computed } from 'vue'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
import MvComment from '@/base-ui/comment'

export function InitDoing() {
  const commentRef = ref<InstanceType<typeof MvComment>>()
  const videoRef = ref<HTMLElement>()
  const store = useStore()
  const route = useRoute()
  const id = ref(0)
  id.value = Number(route.params.id)
  nextTick(() => {
    commentRef.value?.getVideoComment(id.value, 0, 20)
  })
  const handleTop = () => {
    videoRef.value!.scrollTop = 450
  }
  const commentCount = computed(() => {
    return store.state.mv.mvDetailInfo?.commentCount
  })
  const topMenu = computed(() => {
    return store.state.mv.topMenu
  })
  return {
    id,
    commentRef,
    videoRef,
    handleTop,
    commentCount,
    topMenu
  }
}
